#!/var/bin/python
# -*- coding: utf-8 -*-
#######################
#	获取99114黄页信息
#######################

import sys
import time
import urllib
import re
from bs4 import BeautifulSoup
import io
import os
dirs = os.path.abspath(os.path.dirname(__file__)+"/../Config")
os.sys.path.append(dirs)   #将上上级目录加载到python的环境变量中
# os.sys.path.append("D:/job/crawler/Config")
from config import conn,driver,logpath
from selenium.webdriver.common.keys import Keys  #selenium 输入需要引入keys包
cur = conn.cursor()
for i in range(0,840):
	start = i*1000
	sql = "insert into enterpriselist2 (province,city,counties,ename) select distinct province,city,counties,ename from enterpriselist limit %d,1000" % start
	try:
		cur.execute(sql)
		conn.commit()
	except Exception as e:
		print("Failed to add data...",sql)

	# sql2 = "select ename from enterpriselist2 limit %d,1000" % start
	# cur.execute(sql2)
	# res = cur.fetchall()
	# for r in res:
	# 	sql3 = "select province,city,counties,page from enterpriselist where ename='%s' limit 1" % r[0]
	# 	cur.execute(sql3)
	# 	res2 = cur.fetchone()

	# 	sql4 = "update enterpriselist2 set province='%s',city='%s',counties='%s',page=%d where ename='%s'" % (res2[0],res2[1],res2[2],res2[3],r[0])
	# 	cur.execute(sql4)
	# 	conn.commit()